#define  _CRT_SECURE_NO_WARNINGS 1
#include"tree.h"

BTNode* BuyBTNode(char x)
{
	BTNode* node = (BTNode*)malloc(sizeof(BTNode));
	node->Data = x;
	node->left = node->right = NULL;

	return node;
}


BTNode* BinaryTreeCreate()
{
	BTNode* nodeA = BuyBTNode('A');
	BTNode* nodeB = BuyBTNode('B');
	BTNode* nodeC = BuyBTNode('C');
	BTNode* nodeD = BuyBTNode('D');
	BTNode* nodeE = BuyBTNode('E');
	BTNode* nodeF = BuyBTNode('F');

	nodeA->left = nodeB;
	nodeA->right = nodeC;
	nodeB->left = nodeD;
	nodeC->left = nodeE;
	nodeC->right = nodeF;

	return nodeA;
}

//前序遍历 根左右
void preOrder(BTNode* root)
{
	if (root == NULL)
	{
		printf("NULL ");
		return;
	}
	printf("%c ", root->Data);
	preOrder(root->left);
	preOrder(root->right);
}
//中序遍历 左根右
void InOrder(BTNode* root)
{
	if (root == NULL)
	{
		printf("NULL ");
		return;
	}
	preOrder(root->left);
	printf("%c ", root->Data);
	preOrder(root->right);
}
//后续遍历 左右根
void postOrder(BTNode* root)
{
	if (root == NULL)
	{
		printf("NULL ");
		return;
	}
	preOrder(root->left);
	preOrder(root->right); 
	printf("%c ", root->Data);
}

